import random
# 生成中奖号码
def generate_lucky_numbers():
    return random.sample(range(1, 34), 8)
# 比较用户号码和中奖号码
def compare_numbers(user_numbers, lucky_numbers):
    correct_count = len(set(user_numbers) & set(lucky_numbers))
    return correct_count
# 模拟购买10000注彩票
def simulate_lottery(lucky_numbers, num_tickets=10000):
    prize_counts = {'一等奖': 0, '二等奖': 0, '三等奖': 0, '四等奖': 0, '未中奖': 0}
    for _ in range(num_tickets):
        user_numbers = random.sample(range(1, 34), 8)
        correct_count = compare_numbers(user_numbers, lucky_numbers)        
        if correct_count == 8:
            prize_counts['一等奖'] += 1
        elif correct_count == 7:
            prize_counts['二等奖'] += 1
        elif correct_count == 6:
            prize_counts['三等奖'] += 1
        elif correct_count == 5:
            prize_counts['四等奖'] += 1
        else:
            prize_counts['未中奖'] += 1
    return prize_counts
# 主程序
if __name__ == "__main__":
    # 生成中奖号码
    lucky_numbers = generate_lucky_numbers()
    print(f"中奖号码: {lucky_numbers}")  
    # 用户输入
    user_numbers = []
    print("请输入8个1到33之间的不同数字，用空格分隔:")
    user_input = input().strip().split()
    if len(user_input) != 8:
        print("输入无效，请确保输入8个数字。")
    else:
        try:
            user_numbers = [int(num) for num in user_input]
            if len(set(user_numbers)) != 8:
                print("输入无效，请确保每个数字都不重复。")
            elif any(num < 1 or num > 33 for num in user_numbers):
                print("输入无效，请确保每个数字在1到33之间。")
            else:
                correct_count = compare_numbers(user_numbers, lucky_numbers)
                if correct_count == 8:
                    print("恭喜您中了一等奖！")
                elif correct_count == 7:
                    print("恭喜您中了二等奖！")
                elif correct_count == 6:
                    print("恭喜您中了三等奖！")
                elif correct_count == 5:
                    print("恭喜您中了四等奖！")
                else:
                    print("未中奖，感谢您的参与！")
        except ValueError:
            print("输入无效，请确保输入的是整数。")  
    # 模拟购买10000注彩票
    prize_counts = simulate_lottery(lucky_numbers)
    print("\n模拟购买10000注彩票的中奖情况:")
    for prize, count in prize_counts.items():
        print(f"{prize}: {count}次")
        